package com.agileai.bpm.interceptor;

import com.agileai.bpm.domain.define.Activity;
import com.agileai.bpm.interceptor.flow.ProcessInvokerInterceptor;
import com.agileai.bpm.interceptor.flow.ProcessLauncherInterceptor;
import com.agileai.bpm.interceptor.jdbc.DBOperateInterceptor;
import com.agileai.bpm.interceptor.rest.RestInvokerInterceptor;
import com.agileai.bpm.model.InterceptorModelDocument.InterceptorModel;

public class InterceptorFactory {
	public BaseInterceptor create(InterceptorModel model,Activity activity){
		BaseInterceptor result = null;
		if (model.getDBOperater() != null){
			result = new DBOperateInterceptor(model,activity);
			result.setName(model.getName());
		}
		else if (model.getRestInvoker() != null){
			result = new RestInvokerInterceptor(model,activity);
			result.setName(model.getName());			
		}
		else if (model.getFlowLauncher() != null){
			result = new ProcessLauncherInterceptor(model,activity);
			result.setName(model.getName());
		}
		else if (model.getWatchInvoker() != null){
			result = new ProcessInvokerInterceptor(model,activity);
			result.setName(model.getName());
		}
		return result;
	}
}